N = 32
Gspeciter = speciter1d(N);
Gspec = specdirect1d(N);
Gfd = fddirect1d(N);
norm(Gspec-Gspeciter,2) / norm(Gspec,2)
norm(Gspec-Gfd,2) / norm(Gspec,2)
Source = (N/2+1:3*N/4);
Target = (1:N/4);
Sspec = svd(Gspec(Target,Source));
Sfd   = svd(Gfd(Target, Source));
rspec = length(find(Sspec/max(Sspec)>1e-4));
rfd   = length(find(Sfd  /max(Sspec)>1e-4));
disp('spectral rank')
rspec
disp('fd rank')
rfd
